package com.qiaotong.colorpicker;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;

import com.qiaotong.colorpicker.widget.WheelColorPicker;

public class WheelActivity extends AppCompatActivity {
    private WheelColorPicker colorPicker;
    private View colorPreview;
    private TextView textView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_wheel);
        colorPicker = findViewById(R.id.colorPicker);
        colorPreview = findViewById(R.id.colorPreview);
        textView = findViewById(R.id.tv_wheel);


        colorPicker.setOnColorChangedListener(new WheelColorPicker.OnColorChangedListener() {
            @Override
            public void onColorChanged(int color) {
                // 处理颜色变化
                colorPreview.setBackgroundColor(color);
                Log.d("ColorPicker", "Selected color: " + Integer.toHexString(color));
                String string = getString(R.string.color_value, color);
                textView.setText(string);
            }
        });

    }
}